//  Api 集中管理
import {API} from "@/global";
import HTTP from "@/utils/request";

class CommonApi extends HTTP {
    login(data: API.IParams) {
        return this.request({url: '/users/login', method: 'POST', data: data})
    }

	register(data: API.IParams) {
        return this.request({url: '/users/register', method: 'POST', data: data})
    }

	getCoursewareIdByCwCode(data: API.IParams) {
		return this.request({url: '/courseware/coursewareCode', method: 'GET', params: data})
	}
	GetClassList() {
		return this.request({url: '/student/class/getClassCreator', method: 'GET'})
	}
	GetCoursewareListByFilter(data: API.IParams){
		return this.request(({url: '/student/courseware/getStudentCourseware' , method: 'POST',data}))
	}

	GetCoursewareInfo(data: API.IParams){
		return this.request(({url: '/api/webstudent.exam_papers/get_quests' , method: 'POST',data}))
	}

	submitUserAnswer(data: API.IParams) {
		return this.request(({url: '/api/webstudent.exam_papers/quest_submit' , method: 'POST',data}))
	}

	fetchCharacterPinYin(data: string) {
		return this.request(({url: `/api/webstudent.exam_papers/retrieve?${data}` , method: 'GET'}))
	}

	judgeStroke(data: string) {
		return this.request(({url: `/hanzi/getretex?${data}` , method: 'GET'}))
	}

	// 获取汉字坐标信息
	getHZPositionInfo(data: string) {
		return this.request(({url: `/static/zi_json/${data}.json` , method: 'GET'}))
	}

	// 开始定时练习接口
	startTimingPractice(data: API.IParams) {
		return this.request(({url: '/api/webstudent.exam_papers/startPracticeExam' , method: 'POST',data}))
	}

	// 获取融课件的状态
	getTimingPracticeStatus(data: API.IParams) {
		return this.request(({url: '/api/webstudent.exam_papers/getPracticeExamStatus' , method: 'POST',data}))
	}
	// 暂停定时练习接口
	pauseTimingPractice(data: API.IParams) {
		return this.request(({url: '/api/webstudent.exam_papers/pausePracticeExam' , method: 'POST',data}))
	}

    generateValidateCode() {
        return this.request(({url: '/users/generateValidateCode' , method: 'GET'}))
    }

	updatePassword(data: API.IParams) {
		return this.request(({url: '/users/updatePassword' , method: 'PUT',data: data}))
	}

	sendEmailCode(data: API.IParams) {
		return this.request(({url: '/users/sendEmailCode' , method: 'POST',params: data}))
	}

}

export default new CommonApi();
